"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Global_1 = require("../models/Global");
// This is a demo code file
// Feel free to delete it
async function default_1(call) {
    const searchParam = call.req.ScanNum; // 假设请求的参数字段名为 ScanNum
    // 首先尝试通过 AssetNum 搜索
    let op = await Global_1.Global.db.collection("Asset").findOne({ AssetNum: searchParam });
    if (!op) {
        // 如果没有找到，则尝试通过 SN 搜索
        op = await Global_1.Global.db.collection("Asset").findOne({ SerialNum: searchParam });
    }
    if (op) {
        call.succ({
            data: {
                Flag: true,
                AssetNum: op.AssetNum,
                SerialNum: op.SerialNum,
                EquipmentName: op.EquipmentName
            }
        });
    }
    else {
        call.succ({
            data: {
                Flag: false,
                AssetNum: "扫描的该条码不在MES资产盘点范围内",
                SerialNum: searchParam,
                EquipmentName: ""
            }
        });
    }
}
exports.default = default_1;
